<template>
  <div id="bg_box">
    <div class="form_box">
      <div class="form_logo">
        <h1 style="line-height: 100px;text-align: center">乐友|登录</h1>
      </div>
      <div class="form_item">
        <p style="color: red">{{ message }}</p>
        <el-input placeholder="请输用户名" v-model="user.userName" label-width="20">
          <template slot="prepend"><i class="el-icon-user"></i></template>
        </el-input>
        <br><br>
        <el-input type="password" placeholder="请输密码" v-model="user.password">
          <template slot="prepend"><i class="el-icon-lock"></i></template>
        </el-input>
      </div>
      <center>
        <el-button style="width: 300px" @click="login()">登录</el-button>
      </center>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      user: {},
      message: ""
    }
  },
  methods: {
    login() {
      this.$axios({
        method: "post",
        url: "/test/login",
        data: this.user
      })
          .then(res => {
            if (res.data != "") {
              this.message = ""
              window.sessionStorage.setItem("auth", res.data)
              this.$router.push({path:'/leyou'})
            } else {
              this.message = "账号或密码错误"
            }
          })
    }
  }
}
</script>

<style>
html, body {
  width: 100%;
  height: 100%;
}

.form_logo {
  width: 600px;
  height: 100px;
}

.form_item {
  width: 600px;
  height: 170px;
}

#bg_box {
  height: 100%;
  background: url("./assets/2.png");
  overflow: hidden;
}

.form_box {
  width: 600px;
  height: 400px;
  background: #fff;
  margin: 0 auto;
  margin-top: 12%;
  border-radius: 15px;
  box-shadow: 6px 6px 12px #000;
  padding-left: 100px;
  padding-right: 100px;
}
</style>